<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
  <p id="p">hello world</p>

    <script>
        /*
        onmouseover  //鼠标移到某元素之上
        onmouseout  //鼠标从某元素移开  
        在事件中，this指向正在执行事件的对象
        */
       var p=document.getElementById("p");
       p.onmouseover=function(){
           this.style.background="red";
       }
       p.onmouseout=function(){
           this.style.background="green";
       }
    </script>

</body>

</html>